package com.xbongbong.paas.service.impl;
import com.xbongbong.paas.service.DataCenterService;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.datawarning.pojo.dto.DataWarningMessageAddDTO;
import com.xbongbong.pro.message.enums.PushTypeEnum;
import com.xbongbong.pro.message.pojo.dto.MessageRabbitMqDTO;
import com.xbongbong.pro.rabbitmq.producer.BaseProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName DataCenterServiceImpl
 * @Description TODO
 * @Author mengna.Deng
 * @Date 2021/6/7 13:57
 * @Version 1.0
 */
@Service("dataCenterService")
public class DataCenterServiceImpl implements DataCenterService {

    private static final Logger LOG = LoggerFactory.getLogger(DataCenterServiceImpl.class);

    @Resource
    BaseProducer baseProducer;

    @Override
    public void dwMessageAdd(DataWarningMessageAddDTO dataWarningMessageAddDTO) {
        try {
            for (MessageRabbitMqDTO mq : dataWarningMessageAddDTO.getMessageRabbitMqDTOList()) {
                baseProducer.sendMessage(PushTypeEnum.DATA_WARNING_PUSH, mq);
            }
        }catch (XbbException e) {
            LOG.error("数据预警消息推送失败");
        }
    }
}
